package com.androwit.engine.mapping.converter.str;

import java.util.UUID;

import com.androwit.engine.mapping.Converter;

public class UuidConverter implements Converter<UUID, String> {

	protected static UuidConverter instance;

	@Override
	public UUID fromConverted(String value) throws Exception {
		return UUID.fromString(value);
	}

	@Override
	public String convert(UUID uuid) throws Exception {
		return uuid == null ? null : uuid.toString();
	}

	public static UuidConverter getInstance() {
		if (instance == null)
			instance = new UuidConverter();
		return instance;
	}

}
